clear
set more off
set matsize 5000


*  Marriages 

use "$data\M_final_dataset.dta" , clear
rename y_survey year

********************************************************************************
*  Table 2: Panel a. Marriages, Males and Females
*  Number of observations in the dataset and summary statistics

preserve 
tab year
gen hrarea= 3
replace hrarea=1 if hbc==0
replace hrarea=2 if ( hbc==257 | hbc==315 | hbc==247 | hbc==248 | hbc==249 | hbc==227 | hbc==233 | hbc==255 | hbc==251 | hbc==244 | hbc==209 | hbc==235  )
lab define rareal 1 "italian"  2 "EU2004/2007" 3 "all other" 
label values hrarea rareal
count
gen nm=1
collapse (sum) nm  (mean) h_agem h_ey , by(hrarea)
tab nm if hrarea==1
tab nm if hrarea==3
tab nm if hrarea==2
restore

preserve
tab yeargen
gen wrarea= 3
replace wrarea=1 if wbc==0
replace wrarea=2 if ( wbc==257 | wbc==315 | wbc==247 | wbc==248 | wbc==249 | wbc==227 | wbc==233 | wbc==255 | wbc==251 | wbc==244 | wbc==209 | wbc==235  )
lab define rareal 1 "italian"  2 "EU2004/2007" 3 "all other" 
label values wrarea rareal
count
gen nm=1
collapse (sum) nm (mean) w_agem w_ey , by(wrarea)
tab nm if wrarea==1
tab nm if wrarea==3
tab nm if wrarea==2
restore



*  Marriages : Spouses' attributes 

use "$data\M_final_dataset.dta" , clear
rename y_survey year

* Family
gen famt=.
replace famt=1 if wbc==0 & hbc==0
replace famt=2 if wbc==0 & hbc!=0
replace famt=3 if wbc!=0 & hbc==0
replace famt=4 if wbc!=0 & hbc!=0
lab define famtl 1 "Wife Native-Husb Native" 2 "Wife Native-Husb Foreign" 3 "Wife Foreign-Husb Native" 4 "Wife Foreign-Husb Foreign"
lab values famt famtl

* Treatment/ Origin
gen nat= wbc
merge m:1 nat using "$data\CodiciStatiEsteri.dta" , keepusing(EUII)
tab _merge
drop _merge
replace EUII=4 if nat==224 
replace EUII=4 if nat==258  
replace EUII=4 if nat==259  
replace EUII=4 if nat==260  
replace EUII=4 if nat==261  
replace EUII=6 if nat==317  
replace EUII=0 if nat==0  
lab define eui3 0 "ITA" 1 "EU15"  2 "EU2004" 3 "EU2007" 4 "EU_Other" 5 "Africa" 6 "Asia" 7 "America_South" 8 "OECD" 
label values EUII eui3
rename EUII weg
drop nat

gen nat= hbc
merge m:1 nat using "$data\CodiciStatiEsteri.dta" , keepusing(EUII)
tab _merge
drop _merge
replace EUII=4 if nat==224 
replace EUII=4 if nat==258  
replace EUII=4 if nat==259  
replace EUII=4 if nat==260  
replace EUII=4 if nat==261  
replace EUII=6 if nat==317  
replace EUII=0 if nat==0  
label values EUII eui3
rename EUII heg
drop nat

* Attributes: age and education

rename h_agem hage
rename w_agem wage
gen hage_se=hage
gen wage_se=wage
gen diffage=hage-wage
gen diffage_se=diffage

rename h_ey heduy
rename w_ey weduy
gen heduy_se=heduy
gen weduy_se=weduy
gen diffeduy=heduy-weduy
gen diffeduy_se=diffeduy


********************************************************************************
*  Figure 8: Panel 1. Homogamous marriages (Age)
*  Spouses' characteristics in homogamous marriages and intermarriages, before enlargement periods (1998-2002)

preserve
keep if hbc==wbc
collapse (mean) hage wage (sem) hage_se wage_se if year<=2002, by(weg)
lab var hage "Husband age"
lab var wage "Wife age"
tab hage if weg==0
tab wage if weg==0
gen hage_upper=hage+1.96*hage_se
gen hage_lower=hage-1.96*hage_se
gen wage_upper=wage+1.96*wage_se
gen wage_lower=wage-1.96*wage_se

gen rank=.
replace rank= 0 if weg==0
replace rank= 1 if weg==8
replace rank= 2 if weg==1
replace rank= 3 if weg==2
replace rank= 4 if weg==4
replace rank= 5 if weg==6
replace rank= 6 if weg==7
replace rank= 7 if weg==3
replace rank= 8 if weg==5
gen hrank=rank-0.05
gen wrank=rank+0.05
gr twoway (scatter hage hrank , msymbol(circle_hollow) mcolor(dknavy)) (rcap hage_upper hage_lower hrank, lcolor(dknavy) ) ///
		(scatter wage wrank , msymbol(diamond_hollow) mcolor(cranberry) ) (rcap wage_upper wage_lower wrank , lcolor(cranberry) ) , ///
        xtick(0(1)8) xsca(r(0 (1) 8)) ylabel(25(5)42, grid)  ///
		xlab( 0 "Italy" 1 "OECD" 2 "EU15" 3 "EU2004" 4"EU Other" 5 "Asia" 6 "South America" 7 "EU2007" 8 "Africa" , angle(30) labs(small)) ///
		xtitle("Spouses' area of origin") ytitle("Age at marriage") title("Age, homogamous marriages")  legend(order(1 "husband" 3 "wife")) ///
		graphregion(color(white)) 
gr copy age_hom, replace
gr export "$output\age_hom.pdf", replace
restore


********************************************************************************
*  Figure 8: Panel 2. Native husband - Foreign wife (Age)
*  Spouses' characteristics in homogamous marriages and intermarriages, before enlargement periods (1998-2002)

preserve
tab famt
keep if famt==3 | famt==1
collapse (mean) hage wage (sem) hage_se wage_se if year<=2002, by(weg)
lab var hage "Husband age"
lab var wage "Wife age"
tab hage if weg==0
tab wage if weg==0
gen hage_upper=hage+1.96*hage_se
gen hage_lower=hage-1.96*hage_se
gen wage_upper=wage+1.96*wage_se
gen wage_lower=wage-1.96*wage_se

gen rank=.
replace rank= 0 if weg==0
replace rank= 1 if weg==8
replace rank= 2 if weg==1
replace rank= 3 if weg==2
replace rank= 4 if weg==4
replace rank= 5 if weg==6
replace rank= 6 if weg==7
replace rank= 7 if weg==3
replace rank= 8 if weg==5
gen hrank=rank-0.05
gen wrank=rank+0.05
gr twoway (scatter hage hrank , msymbol(circle_hollow) mcolor(dknavy)) (rcap hage_upper hage_lower hrank, lcolor(dknavy) ) ///
		(scatter wage wrank , msymbol(diamond_hollow) mcolor(cranberry) ) (rcap wage_upper wage_lower wrank , lcolor(cranberry) ) , ///
        xtick(0(1)8) xsca(r(0 (1) 8))  ylabel(25(5)42, grid)  ///
		xlab( 0 "Italy" 1 "OECD" 2 "EU15" 3 "EU2004" 4"EU Other" 5 "Asia" 6 "South America" 7 "EU2007" 8 "Africa" , angle(30) labs(small)) ///
		xtitle("Wife's area of origin") ytitle("Age at marriage") title("Age, native husband - foreign wife")  legend(order(1 "husband" 3 "wife")) ///
		graphregion(color(white)) 
gr copy age_hetw, replace
gr export "$output\age_hetw.pdf", replace
restore


********************************************************************************
*  Figure 8: Panel 3. Native wife - Foreign husband (Age)
*  Spouses' characteristics in homogamous marriages and intermarriages, before enlargement periods (1998-2002)

preserve
tab famt
keep if famt==2 | famt==1
collapse (mean) hage wage (sem) hage_se wage_se if year<=2002, by(heg)
lab var hage "Husband age"
lab var wage "Wife age"
tab hage if heg==0
tab wage if heg==0
gen hage_upper=hage+1.96*hage_se
gen hage_lower=hage-1.96*hage_se
gen wage_upper=wage+1.96*wage_se
gen wage_lower=wage-1.96*wage_se

gen rank=.
replace rank= 0 if heg==0
replace rank= 1 if heg==8
replace rank= 2 if heg==1
replace rank= 3 if heg==2
replace rank= 4 if heg==4
replace rank= 5 if heg==6
replace rank= 6 if heg==7
replace rank= 7 if heg==3
replace rank= 8 if heg==5
gen hrank=rank-0.05
gen wrank=rank+0.05
gr twoway (scatter hage hrank , msymbol(circle_hollow) mcolor(dknavy)) (rcap hage_upper hage_lower hrank, lcolor(dknavy) ) ///
		(scatter wage wrank , msymbol(diamond_hollow) mcolor(cranberry) ) (rcap wage_upper wage_lower wrank , lcolor(cranberry) ) , ///
        xtick(0(1)8) xsca(r(0 (1) 8))  ylabel(25(5)42, grid) ///
		xlab( 0 "Italy" 1 "OECD" 2 "EU15" 3 "EU2004" 4"EU Other" 5 "Asia" 6 "South America" 7 "EU2007" 8 "Africa" , angle(30) labs(small)) ///
		xtitle("Husband's area of origin") ytitle("Age at marriage") title("Age, native wife - foreign husband")  legend(order(1 "husband" 3 "wife")) ///
		graphregion(color(white)) 
gr copy age_heth, replace
gr export "$output\age_heth.pdf", replace
restore


********************************************************************************
*  Figure 8: Panel 4. Homogamous marriages (Education)
*  Spouses' characteristics in homogamous marriages and intermarriages, before enlargement periods (1998-2002)

preserve
keep if hbc==wbc
collapse (mean) heduy weduy (sem) heduy_se weduy_se if year<=2002, by(weg)
lab var heduy "Husband years of education"
lab var heduy "Wife years of education"
tab heduy if weg==0
tab weduy if weg==0
gen heduy_upper=heduy+1.96*heduy_se
gen heduy_lower=heduy-1.96*heduy_se
gen weduy_upper=weduy+1.96*weduy_se
gen weduy_lower=weduy-1.96*weduy_se

gen rank=.
replace rank= 0 if weg==0
replace rank= 1 if weg==8
replace rank= 2 if weg==1
replace rank= 3 if weg==2
replace rank= 4 if weg==4
replace rank= 5 if weg==6
replace rank= 6 if weg==7
replace rank= 7 if weg==3
replace rank= 8 if weg==5
gen hrank=rank-0.05
gen wrank=rank+0.05
gr twoway (scatter heduy hrank , msymbol(circle_hollow) mcolor(dknavy)) (rcap heduy_upper heduy_lower hrank, lcolor(dknavy) ) ///
		(scatter weduy wrank , msymbol(diamond_hollow) mcolor(cranberry) ) (rcap weduy_upper weduy_lower wrank , lcolor(cranberry) ) , ///
        xtick(0(1)8) xsca(r(0 (1) 8))  ylabel(9(1)13, grid)  ///
		xlab( 0 "Italy" 1 "OECD" 2 "EU15" 3 "EU2004" 4"EU Other" 5 "Asia" 6 "South America" 7 "EU2007" 8 "Africa" , angle(30) labs(small)) ///
		xtitle("Spouses' area of origin") ytitle("Years of education") title("Education, homogamous marriages") legend(order(1 "husband" 3 "wife")) ///
		graphregion(color(white)) 
gr copy eduy_hom, replace
gr export "$output\eduy_hom.pdf", replace
restore


********************************************************************************
*  Figure 8: Panel 5. Native husband - Foreign wife (Education)
*  Spouses' characteristics in homogamous marriages and intermarriages, before enlargement periods (1998-2002)

preserve
tab famt
keep if famt==3 | famt==1
collapse (mean) heduy weduy (sem) heduy_se weduy_se if year<=2002, by(weg)
lab var heduy "Husband years of education"
lab var weduy "Wife years of education"
tab heduy if weg==0
tab weduy if weg==0
gen heduy_upper=heduy+1.96*heduy_se
gen heduy_lower=heduy-1.96*heduy_se
gen weduy_upper=weduy+1.96*weduy_se
gen weduy_lower=weduy-1.96*weduy_se

gen rank=.
replace rank= 0 if weg==0
replace rank= 1 if weg==8
replace rank= 2 if weg==1
replace rank= 3 if weg==2
replace rank= 4 if weg==4
replace rank= 5 if weg==6
replace rank= 6 if weg==7
replace rank= 7 if weg==3
replace rank= 8 if weg==5
gen hrank=rank-0.05
gen wrank=rank+0.05
gr twoway (scatter heduy hrank , msymbol(circle_hollow) mcolor(dknavy)) (rcap heduy_upper heduy_lower hrank, lcolor(dknavy) ) ///
		(scatter weduy wrank , msymbol(diamond_hollow) mcolor(cranberry) ) (rcap weduy_upper weduy_lower wrank , lcolor(cranberry) ) , ///
        xtick(0(1)8) xsca(r(0 (1) 8))   ylabel(9(1)13, grid) ///
		xlab( 0 "Italy" 1 "OECD" 2 "EU15" 3 "EU2004" 4"EU Other" 5 "Asia" 6 "South America" 7 "EU2007" 8 "Africa" , angle(30) labs(small)) ///
		xtitle("Wife's area of origin") ytitle("Years of education") title("Education, native husband - foreign wife")  legend(order(1 "husband" 3 "wife")) ///
		graphregion(color(white)) 
gr copy eduy_hetw, replace
gr export "$output\eduy_hetw.pdf", replace
restore


********************************************************************************
*  Figure 8: Panel 6. Native wife - Foreign husband (Education)
*  Spouses' characteristics in homogamous marriages and intermarriages, before enlargement periods (1998-2002)

preserve
tab famt
keep if famt==2 | famt==1
collapse (mean) heduy weduy (sem) heduy_se weduy_se if year<=2002, by(heg)
lab var heduy "Husband age"
lab var weduy "Wife age"
tab heduy if heg==0
tab weduy if heg==0
gen heduy_upper=heduy+1.96*heduy_se
gen heduy_lower=heduy-1.96*heduy_se
gen weduy_upper=weduy+1.96*weduy_se
gen weduy_lower=weduy-1.96*weduy_se

gen rank=.
replace rank= 0 if heg==0
replace rank= 1 if heg==8
replace rank= 2 if heg==1
replace rank= 3 if heg==2
replace rank= 4 if heg==4
replace rank= 5 if heg==6
replace rank= 6 if heg==7
replace rank= 7 if heg==3
replace rank= 8 if heg==5
gen hrank=rank-0.05
gen wrank=rank+0.05
gr twoway (scatter heduy hrank , msymbol(circle_hollow) mcolor(dknavy)) (rcap heduy_upper heduy_lower hrank, lcolor(dknavy) ) ///
		(scatter weduy wrank , msymbol(diamond_hollow) mcolor(cranberry) ) (rcap weduy_upper weduy_lower wrank , lcolor(cranberry) ) , ///
        xtick(0(1)8) xsca(r(0 (1) 8))  ylabel(9(1)13, grid) ///
		xlab( 0 "Italy" 1 "OECD" 2 "EU15" 3 "EU2004" 4"EU Other" 5 "Asia" 6 "South America" 7 "EU2007" 8 "Africa" , angle(30) labs(small)) ///
		xtitle("Husband's area of origin") ytitle("Years of education") title("Education, native wife - foreign husband")  legend(order(1 "husband" 3 "wife")) ///
		graphregion(color(white)) 
gr copy eduy_heth, replace
gr export "$output\eduy_heth.pdf", replace
restore

grc1leg  age_hom age_hetw age_heth eduy_hom eduy_hetw eduy_heth,  legendfrom(age_hom) scale(.9)




********************************************************************************
*  Table A8: Columns 1-6 
*  Spouses' characteristics, before and after the EU enlargements

gen onenative= (wbc==0|hbc==0)
tab onenative 
gen hnewEU=(heg==2|heg==3)
gen hEU2004=(heg==2)
gen hEU2007=(heg==3)
gen wnewEU=(weg==2|weg==3)
gen wEU2004=(weg==2)
gen wEU2007=(weg==3)

gen hpost=1 if heg==2&year>=2004
replace hpost=1 if heg==3&year>=2007
gen wpost=1 if weg==2&year>=2004
replace wpost=1 if weg==3&year>=2007
mvencode hpost wpost, mv(0)

gen hnewEUxhpost=hnewEU*hpost
gen wnewEUxwpost=wnewEU*wpost
gen hwbc=hbc*1000+wbc
gen fe=string(weg)+"X"+string(heg)
gen feclust=fe+"X"+string(year)

**** time varying coefficients ****
forvalues y=1999/2010 {
gen hEU2004xy$_y=hEU2004*(year==$_y)
gen wEU2004xy$_y=wEU2004*(year==$_y)
gen hEU2007xy$_y=hEU2007*(year==$_y)
gen wEU2007xy$_y=wEU2007*(year==$_y)
}

reghdfe diffage wnewEUxwpost hnewEUxhpost , absorb(hwbc year) cluster(feclust)
outreg2 using "$output\ageedudiffsregress", replace bdec(3) excel nonotes keep(wnewEUxwpost hnewEUxhpost)
reghdfe diffage wnewEUxwpost hnewEUxhpost if onenative==1, absorb(hwbc year) cluster(feclust)
outreg2 using "$output\ageedudiffsregress", append bdec(3) excel nonotes keep(wnewEUxwpost hnewEUxhpost)

reghdfe diffeduy wnewEUxwpost hnewEUxhpost , absorb(hwbc year) cluster(feclust)
outreg2 using "$output\ageedudiffsregress", append bdec(3) excel nonotes keep(wnewEUxwpost hnewEUxhpost)
reghdfe diffeduy wnewEUxwpost hnewEUxhpost if onenative==1, absorb(hwbc year) cluster(feclust)
outreg2 using "$output\ageedudiffsregress", append bdec(3) excel nonotes keep(wnewEUxwpost hnewEUxhpost)

gen deltaedu_dum=1 if deltaeduy>0
replace deltaedu_dum=-1 if deltaeduy<0
replace deltaedu_dum=0 if deltaeduy==0
reghdfe deltaedu_dum wnewEUxwpost hnewEUxhpost , absorb(hwbc year) cluster(feclust)
outreg2 using "$output\ageedudiffsregress", append bdec(3) excel nonotes keep(wnewEUxwpost hnewEUxhpost)
reghdfe deltaedu_dum wnewEUxwpost hnewEUxhpost if onenative==1, absorb(hwbc year) cluster(feclust)
outreg2 using "$output\ageedudiffsregress", append bdec(3) excel nonotes keep(wnewEUxwpost hnewEUxhpost)





*  Separations  

use "$data\MS_final_dataset.dta" , clear

********************************************************************************
*  Table 2: Panel b. Separations, Males and Females
*  Number of observations in the dataset and summary statistics

gen hrarea= 3
replace hrarea=1 if hbc==0
replace hrarea=2 if ( hbc==257 | hbc==315 | hbc==247 | hbc==248 | hbc==249 | hbc==227 | hbc==233 | hbc==255 | hbc==251 | hbc==244 | hbc==209 | hbc==235  )
lab define rareal 1 "italian"  2 "EU2004/2007" 3 "all other" 
label values hrarea rareal

gen wrarea= 3
replace wrarea=1 if wbc==0
replace wrarea=2 if ( wbc==257 | wbc==315 | wbc==247 | wbc==248 | wbc==249 | wbc==227 | wbc==233 | wbc==255 | wbc==251 | wbc==244 | wbc==209 | wbc==235  )
label values wrarea rareal

count
keep if separated==1
count
gen md = (msdate-mmdate)
order sepdate y_survey ym md mmdate msdate
gen h_agesep = y_survey-h_born_y
codebook h_agesep
gen w_agesep = y_survey-w_born_y
codebook w_agesep

preserve
collapse (sum) separated  (mean) md h_agem h_ey h_agesep , by(hrarea)
restore
preserve
collapse (sum) separated  (mean) md w_agem w_ey w_agesep , by(wrarea)
restore




*  Singles from Census 2001 and Census 2011
*  Census 2001

clear
set more off

use "$data\census2001.dta" , clear

label define gender 1 "maschio" 2 "femmina"
label define codici_province 001 "Torino" 002 "Vercelli" 003 "Novara" 004 "Cuneo" 005 "Asti" 006 "Alessandria" 096 "Biella" 103 "Verbano-Cusio-Ossola" ///
007 "Valle D'Aosta/Valle d'Aoste" 012 "Varese" 013 "Como" 014 "Sondrio" 015 "Milano" 016 "Bergamo" 017 "Brescia" 018 "Pavia" 019 "Cremona" 020 "Mantova" 097 "Lecco" 098 "Lodi" 108 ///
"Monza e della Brianza" 021 "Bolzano/Bozen" 022 "Trento" 023 "Verona" 024 "Vicenza" 025 "Belluno" 026 "Treviso" 027 "Venezia" 028 "Padova" 029 "Rovigo" 030 "Udine" 031 "Gorizia" ///
032 "Trieste" 093 "Pordenone" 008 "Imperia" 009 "Savona" 010 "Genova" 011 "La Spezia" 033 "Piacenza" 034 "Parma" 035 "Reggio nell'Emilia" 036 "Modena" 037 "Bologna" 038 "Ferrara" ///
039 "Ravenna" 040 "Forl-Cesena" 099 "Rimini" 045 "Massa-Carrara" 046 "Lucca" 047 "Pistoia" 048 "Firenze" 049 "Livorno" 050 "Pisa" 051 "Arezzo" 052 "Siena" 053 "Grosseto" 100 "Prato" ///
054	"Perugia" 055 "Terni" 041 "Pesaro e Urbino" 042	"Ancona" 043	"Macerata" 044	"Ascoli Piceno" 109	"Fermo" 056	"Viterbo" 057	"Rieti" 058	"Roma" 059	"Latina" 060 "Frosinone" ///
066	"L'Aquila" 067	"Teramo" 068	"Pescara" 069	"Chieti" 070	"Campobasso" 094	"Isernia" 061	"Caserta" 062	"Benevento" 063	"Napoli" 064	"Avellino" 065	"Salerno" ///
071 "Foggia" 072	"Bari" 073	"Taranto" 074	"Brindisi" 075	"Lecce" 110	"Barletta-Andria-Trani" 076	"Potenza" 077	"Matera" 078	"Cosenza" 079	"Catanzaro" ///
080	"Reggio di Calabria" 101	"Crotone" 102	"Vibo Valentia" 081	"Trapani" 082	"Palermo" 083	"Messina" 084	"Agrigento" 085	"Caltanissetta" 086	"Enna" 087	"Catania" ///
088	"Ragusa" 089	"Siracusa" 090	"Sassari" 091	"Nuoro" 092	"Cagliari" 095	"Oristano" 104	"Olbia-Tempio" 105	"Ogliastra" 106	"Medio Campidano" 107	"Carbonia-Iglesias"

label define cittadinanza 000 "nullo" 100 "Italiana"  201 "Albania"   202	"Andorra" 203 "Austria" 206	"Belgio" 209 "Bulgaria" 210 "Ex-cecoslovacchia" 212	"Danimarca" 214	"Finlandia" 215	"Francia" 216 "Germania" 219 "Regno Unito" ///	
220	"Grecia" 221 "Irlanda" 223 "Islanda" 225 "Liechtenstein" 226 "Lussemburgo" 227	"Malta" 229	"Monaco" 231 "Norvegia" 232	"Paesi Bassi" 233 "Polonia" 234	"Portogallo" ///	
235	"Romania" 236 "San Marino" 239	"Spagna" 240 "Svezia" 241 "Svizzera" 243 "Ucraina" 244	"Ungheria" 245	"Russa,Federazione" 246	"Santa Sede" 247 "Estonia" 248 "Lettonia" ///
249	"Lituania" 250 "Croazia" 251 "Slovenia" 252	"Bosnia-Erzegovina" 253	"Macedonia,ex Repubblica Jugoslava di" 254 "Moldova" 255 "Slovacchia" 256 "Bielorussia" 257	"Ceca,Repubblica" ///	
270	"Montenegro" 271 "Serbia, Repubblica di" 301 "Afghanistan" 302 "Arabia Saudita" 304	"Bahrein" 305 "Bangladesh" 306 "Bhutan" 307	"Myanmar (ex Birmania)" 309	"Brunei" ///
310	"Cambogia" 311 "Sri Lanka (ex Ceylon)" 314	"Cinese, Repubblica Popolare" 315 "Cipro" 319 "Corea, Repubblica Popolare Democratica (Corea del Nord)" ///
320	"Corea, Repubblica (Corea del Sud)"  322	"Emirati Arabi Uniti" 323	"Filippine" 324	"Territori dell'Autonomia Palestinese" 	326	"Giappone" 	327	"Giordania" 330	"India" ///	
331	"Indonesia" 332	"Iran, Repubblica Islamica del" 333	"Iraq" 334	"Israele" 335 "Kuwait" 336 "Laos"  337 "Libano" 338 "Timor Orientale" 339 "Maldive" 340 "Malaysia" 341 "Mongolia" ///	
342	"Nepal" 343	"Oman" 344 "Pakistan" 345 "Qatar" 346	"Singapore" 348	"Siria" 349	"Thailandia" 351 "Turchia" 353 "Vietnam" 354 "Yemen" 356 "Kazakhstan" 357 "Uzbekistan" ///	
358	"Armenia" 359 "Azerbaigian" 360	"Georgia" 361 "Kirghizistan" 362 "Tagikistan" 363 "Taiwan (ex Formosa)" 364	"Turkmenistan" 401 "Algeria" 402 "Angola" 404 "Costa d'Avorio" ///	
406	"Benin (ex Dahomey)" 408 "Botswana" 409	"Burkina Faso (ex Alto Volta)" 410	"Burundi" 411 "Camerun" 413	"Capo Verde" 414 "Centrafricana, Repubblica" 415 "Ciad" 417	"Comore" ///	
418	"Congo (Repubblica del)" 419 "Egitto" 420 "Etiopia"  421	"Gabon" 422	"Gambia" 423 "Ghana" 424 "Gibuti" 425 "Guinea" 426 "GuineaBissau" 427 "Guinea Equatoriale" 428	"Kenya" ///	
429	"Lesotho" 430	"Liberia" 431 "Libia" 432 "Madagascar" 434	"Malawi" 435 "Mali" 436	"Marocco"  437	"Mauritania" 438 "Mauritius" 440 "Mozambico" 441 "Namibia" 442	"Niger" ///	
443	"Nigeria" 446 "Ruanda" 448	"San tome e Principe" 449 "Seychelles" 450	"Senegal" 451 "Sierra Leone" 453 "Somalia" 454	"Sud Africa" 455 "Sudan" 456 "Swaziland" 457 "Tanzania" ///	
458	"Togo" 460	"Tunisia" 461 "Uganda" 463	"Congo, Repubblica democratica del (ex Zaire)"  464 "Zambia" 465	"Zimbabwe (ex Rhodesia)" 466 "Eritrea" 503 "Antigua e Barbuda" ///	
505	"Bahamas" 506 "Barbados" 507 "Belize" 509 "Canada" 513	"Costa Rica" 514 "Cuba" 515	"Dominica" 516	"Dominicana, Repubblica" 517 "El Salvador" 518	"Giamaica" 519 "Grenada" ///	
523	"Guatemala" 524	"Haiti" 525	"Honduras" 527	"Messico" 529 "Nicaragua" 530 "Panama" 532	"Saint Lucia" 533 "Saint Vincent e Grenadine" 534 "Saint Kitts e Nevis" ///
536	"Stati Uniti d'America" 602	"Argentina"  604	"Bolivia" 605	"Brasile" 606 "Cile" 608 "Colombia" 609	"Ecuador" 612 "Guyana" 614	"Paraguay" 615	"Peru" 16 "Suriname" ///	
617	"Trinidad e Tobago" 618	"Uruguay" 619 "Venezuela" 701 "Australia" 703 "Figi" 708 "Kiribati" 712	"Marshall, Isole" 713 "Micronesia, Stati Federati" 715 "Nauru" 719 "Nuova Zelanda" ///	
720	"Palau" 721	"Papua Nuova Guinea" 725 "Salomone, Isole" 727	"Samoa" 730	"Tonga" 731	"Tuvalu" 732 "Vanuatu" 999 "APOLIDE" 888 "altro" 777 "non indicato"

label define codici_regioni  1 "Piemonte" 2 "Valle D'Aosta" 3 "Lombardia" 4 "Trentino Alto-Adige" 5 "Veneto" 6 "Friuli Venezia Giulia" 7 "Liguria" 8 "Emilia Romagna" ///
9 "Toscana" 10 "Umbria" 11 "Marche" 12 "Lazio" 13 "Abruzzo" 14 "Molise" 15 "Campania" 16 "Puglia" 17 "Basilicata" 18 "Calabria" 19 "Sicilia" 20 "Sardegna" 

lab define relationl 1 "Intestatario del foglio di famiglia"   2 "Coniuge dell'intestario"     3 "Convivente dell'intestatario"     4 "Figlio/a"  5 "Figlio/a"   6 "Figlio/a"    7 "Genitore (o coniuge del genitore)"    8 "Suocero/a" ///    
                     9 "Fratello/sorella" 10 "Fratello/sorella"    11 "Coniuge del fratello/sorella"     12 "Genero/nuora"   13 "Nipote (figlio/a di un figlio/a)"   14 "Nipote"    15 "Altro parente dell'intestatario"    16 "Altra persona convivente senza legami di parentela" 

rename codpro provincia
lab values provincia codici_province
rename codcom cod_mun
lab var cod_mun "codice comune"
rename progfam idf
lab var idf "identificativo famiglia"
rename progper idc
lab var idc "identificativo individui per comune"
rename relpar relation
lab var relation "relazioen di parentela"
lab values relation relationl
rename sesso sex 
lab values sex gender 
rename gnas born_d
rename mnas born_m 
rename anas born_y 

* Age

gen age =2001-born_y
drop if age<18 // keep maggiorenni
count
gen agec= .
replace agec=1 if age<=24
replace agec=2 if age >=25 & age<30
replace agec=3 if age >=30 & age<35
replace agec=4 if age >=35 & age<40
replace agec=5 if age >=40 & age<45
replace agec=6 if age >=45
lab define agecl 1 "24-" 2 "25-29" 3 "30-34" 4 "35-39" 5 "40-44" 6 "45+"
lab values agec agecl

*  Education 

rename titstu educ
destring educ , replace
tab educ
label define educl  1 "no leggere" 2 "no titolo" 3 "elementari" 4 "medie" 5 "classico" 6 "scientifico" 7 "linguistico" 8 "artistico" ///
                    9 "professionale" 10 "magistrale" 11 "istituto arte" 12 "tecnico" 13 "magistrale" 14 "diploma non univ" 15 "diploma univ" 16 "laurea"  
lab values educ educl
gen high = educ>=5
lab var high "high school"
tab high
gen yedu= .
replace yedu= 0 if educ==1
replace yedu= 2 if educ==2
replace yedu= 5 if educ==3
replace yedu= 8 if educ==4
replace yedu= 13 if educ==5
replace yedu= 13 if educ==6
replace yedu= 13 if educ==7
replace yedu= 13 if educ==8
replace yedu= 11 if educ==9
replace yedu= 13 if educ==10
replace yedu= 12 if educ==11
replace yedu= 13 if educ==12
replace yedu= 13 if educ==13
replace yedu= 16 if educ==14
replace yedu= 16 if educ==15
replace yedu= 18 if educ==16

* Marital status

rename staciv ms
lab var ms "marital status"
label define stato_civile 1 "celibe/nubile" 2 "coniugato" 3 "separato di fatto" 4 "separato legalmente" 5 "divorziato" 6 "vedovo"
lab values ms stato_civile
rename mmat m_marriage
rename amat y_marriage
tab ms
gen single= ms==1 | ms==4 | ms==5 | ms==6 // single sono celibi separati div e vedovi
tab single

* Origin 

rename anntra italy_year
lab var italy_year "anno del trasferimento in italia"
rename pronas born_prov 
lab var born_prov "provincia nascita"
lab values born_prov codici_province
rename estnas born_country
lab values born_country cittadinanza
rename cittad nationality
lab define nat 1 "italiano" 2 "straniero"
lab values nationality nat
rename stac nationality2
lab var nationality2 "cittadinanza"
lab values nationality2 cittadinanza
codebook born_country
gen bc=0
replace bc= born_country if born_country!=.
replace bc= nationality2 if born_country==. & nationality2!=. // sg
lab var bc "individual country of origin and SG"
codebook bc
drop if bc==999 | bc==998 // apolidi o altro
gen nat= bc
merge m:1 nat using "$data\CodiciStatiEsteri.dta" , keepusing(EUII)
tab _merge
drop _merge
replace EUII=0 if bc==0
replace EUII=5 if nat==224  
replace EUII=6 if nat==258  
replace EUII=6 if nat==259  
replace EUII=6 if nat==260  
replace EUII=6 if nat==261  
replace EUII=9 if nat==317  
rename EUII group
drop nat 

gen origin=.
replace origin=0 if group==0 
replace origin=1 if group==1
replace origin=2 if group==2 | group==3
replace origin=3 if group==4 
replace origin=4 if group==5 
replace origin=5 if group==6 
replace origin=6 if group==7 
replace origin=7 if group==8 
lab define lorigin 0 "italian" 1 "eu" 2 "eu10+eu2" 3 "euother" 4 "africa" 5 "asia" 6 "america" 7 "oecd"
lab values origin lorigin
drop if origin==.
drop nat

* Keep singles

keep if single==1
drop if age<18 
drop if age>61 
tab sex
gen female = sex==2
gen male =   sex==1
gen y = 2001
keep  y age sex yedu educ origin 

********************************************************************************
*  Table 2: Panel c. Singles in 2001, Males and Females
*  Number of observations in the dataset and summary statistics

gen area= 2
replace area=1 if origin==0
replace area=3 if origin==2
lab define areal 1 "italian"  3 "EU2004/2007" 2 "all other" 
label values area areal
collapse (sum) single (mean) age yedu  , by( area sex ) 



* Census 2011

clear
set more off

global allprov agrigento alessandria  ancona arezzo ascolipiceno asti avellino barletta belluno benevento bergamo biella ///
bari bologna bolzano brescia brindisi cagliari caltanissetta campobasso carboniaiglesias caserta catania catanzaro ///
chieti como cosenza cremona crotone cuneo enna fermo ferrara firenze foggia forli frosinone genova gorizia grosseto ///
imperia isernia laquila laspezia latina lecce lecco livorno lodi lucca macerata mantova massacarrara matera mediocampidano messina ///
milano modena monzabrianza napoli novara nuoro ogliastra olbia oristano padova palermo parma pavia perugia pesarourbino pescara piacenza pisa pistoia ///
pordenone potenza prato ragusa ravenna reggiocalabria reggioemilia rieti rimini roma rovigo salerno sassari savona siena siracusa sondrio ///
taranto teramo terni torino trapani trento treviso trieste udine valleaosta varese venezia verbano vercelli verona vibovalentia vicenza viterbo

foreach name in $allprov {

use "$c2011\I2011_`name'.dta" , clear

label define gender 1 "maschio" 2 "femmina"
label define codici_province 001 "Torino" 002 "Vercelli" 003 "Novara" 004 "Cuneo" 005 "Asti" 006 "Alessandria" 096 "Biella" 103 "Verbano-Cusio-Ossola" ///
007 "Valle D'Aosta/Valle d'Aoste" 012 "Varese" 013 "Como" 014 "Sondrio" 015 "Milano" 016 "Bergamo" 017 "Brescia" 018 "Pavia" 019 "Cremona" 020 "Mantova" 097 "Lecco" 098 "Lodi" 108 ///
"Monza e della Brianza" 021 "Bolzano/Bozen" 022 "Trento" 023 "Verona" 024 "Vicenza" 025 "Belluno" 026 "Treviso" 027 "Venezia" 028 "Padova" 029 "Rovigo" 030 "Udine" 031 "Gorizia" ///
032 "Trieste" 093 "Pordenone" 008 "Imperia" 009 "Savona" 010 "Genova" 011 "La Spezia" 033 "Piacenza" 034 "Parma" 035 "Reggio nell'Emilia" 036 "Modena" 037 "Bologna" 038 "Ferrara" ///
039 "Ravenna" 040 "Forli-Cesena" 099 "Rimini" 045 "Massa-Carrara" 046 "Lucca" 047 "Pistoia" 048 "Firenze" 049 "Livorno" 050 "Pisa" 051 "Arezzo" 052 "Siena" 053 "Grosseto" 100 "Prato" ///
054	"Perugia" 055 "Terni" 041 "Pesaro e Urbino" 042	"Ancona" 043	"Macerata" 044	"Ascoli Piceno" 109	"Fermo" 056	"Viterbo" 057	"Rieti" 058	"Roma" 059	"Latina" 060 "Frosinone" ///
066	"L'Aquila" 067	"Teramo" 068	"Pescara" 069	"Chieti" 070	"Campobasso" 094	"Isernia" 061	"Caserta" 062	"Benevento" 063	"Napoli" 064	"Avellino" 065	"Salerno" ///
071 "Foggia" 072	"Bari" 073	"Taranto" 074	"Brindisi" 075	"Lecce" 110	"Barletta-Andria-Trani" 076	"Potenza" 077	"Matera" 078	"Cosenza" 079	"Catanzaro" ///
080	"Reggio di Calabria" 101	"Crotone" 102	"Vibo Valentia" 081	"Trapani" 082	"Palermo" 083	"Messina" 084	"Agrigento" 085	"Caltanissetta" 086	"Enna" 087	"Catania" ///
088	"Ragusa" 089	"Siracusa" 090	"Sassari" 091	"Nuoro" 092	"Cagliari" 095	"Oristano" 104	"Olbia-Tempio" 105	"Ogliastra" 106	"Medio Campidano" 107	"Carbonia-Iglesias"

label define cittadinanza 000 "nullo" 100 "Italiana"  201 "Albania"   202	"Andorra" 203 "Austria" 206	"Belgio" 209 "Bulgaria" 210 "Ex-cecoslovacchia" 212	"Danimarca" 214	"Finlandia" 215	"Francia" 216 "Germania" 219 "Regno Unito" ///	
220	"Grecia" 221 "Irlanda" 223 "Islanda" 225 "Liechtenstein" 226 "Lussemburgo" 227	"Malta" 229	"Monaco" 231 "Norvegia" 232	"Paesi Bassi" 233 "Polonia" 234	"Portogallo" ///	
235	"Romania" 236 "San Marino" 239	"Spagna" 240 "Svezia" 241 "Svizzera" 243 "Ucraina" 244	"Ungheria" 245	"Russa,Federazione" 246	"Santa Sede" 247 "Estonia" 248 "Lettonia" ///
249	"Lituania" 250 "Croazia" 251 "Slovenia" 252	"Bosnia-Erzegovina" 253	"Macedonia,ex Repubblica Jugoslava di" 254 "Moldova" 255 "Slovacchia" 256 "Bielorussia" 257	"Ceca,Repubblica" ///	
270	"Montenegro" 271 "Serbia, Repubblica di" 301 "Afghanistan" 302 "Arabia Saudita" 304	"Bahrein" 305 "Bangladesh" 306 "Bhutan" 307	"Myanmar (ex Birmania)" 309	"Brunei" ///
310	"Cambogia" 311 "Sri Lanka (ex Ceylon)" 314	"Cinese, Repubblica Popolare" 315 "Cipro" 319 "Corea, Repubblica Popolare Democratica (Corea del Nord)" ///
320	"Corea, Repubblica (Corea del Sud)"  322	"Emirati Arabi Uniti" 323	"Filippine" 324	"Territori dell'Autonomia Palestinese" 	326	"Giappone" 	327	"Giordania" 330	"India" ///	
331	"Indonesia" 332	"Iran, Repubblica Islamica del" 333	"Iraq" 334	"Israele" 335 "Kuwait" 336 "Laos"  337 "Libano" 338 "Timor Orientale" 339 "Maldive" 340 "Malaysia" 341 "Mongolia" ///	
342	"Nepal" 343	"Oman" 344 "Pakistan" 345 "Qatar" 346	"Singapore" 348	"Siria" 349	"Thailandia" 351 "Turchia" 353 "Vietnam" 354 "Yemen" 356 "Kazakhstan" 357 "Uzbekistan" ///	
358	"Armenia" 359 "Azerbaigian" 360	"Georgia" 361 "Kirghizistan" 362 "Tagikistan" 363 "Taiwan (ex Formosa)" 364	"Turkmenistan" 401 "Algeria" 402 "Angola" 404 "Costa d'Avorio" ///	
406	"Benin (ex Dahomey)" 408 "Botswana" 409	"Burkina Faso (ex Alto Volta)" 410	"Burundi" 411 "Camerun" 413	"Capo Verde" 414 "Centrafricana, Repubblica" 415 "Ciad" 417	"Comore" ///	
418	"Congo (Repubblica del)" 419 "Egitto" 420 "Etiopia"  421	"Gabon" 422	"Gambia" 423 "Ghana" 424 "Gibuti" 425 "Guinea" 426 "GuineaBissau" 427 "Guinea Equatoriale" 428	"Kenya" ///	
429	"Lesotho" 430	"Liberia" 431 "Libia" 432 "Madagascar" 434	"Malawi" 435 "Mali" 436	"Marocco"  437	"Mauritania" 438 "Mauritius" 440 "Mozambico" 441 "Namibia" 442	"Niger" ///	
443	"Nigeria" 446 "Ruanda" 448	"San Tome Principe" 449 "Seychelles" 450	"Senegal" 451 "Sierra Leone" 453 "Somalia" 454	"Sud Africa" 455 "Sudan" 456 "Swaziland" 457 "Tanzania" ///	
458	"Togo" 460	"Tunisia" 461 "Uganda" 463	"Congo, Repubblica democratica del (ex Zaire)"  464 "Zambia" 465	"Zimbabwe (ex Rhodesia)" 466 "Eritrea" 503 "Antigua e Barbuda" ///	
505	"Bahamas" 506 "Barbados" 507 "Belize" 509 "Canada" 513	"Costa Rica" 514 "Cuba" 515	"Dominica" 516	"Dominicana, Repubblica" 517 "El Salvador" 518	"Giamaica" 519 "Grenada" ///	
523	"Guatemala" 524	"Haiti" 525	"Honduras" 527	"Messico" 529 "Nicaragua" 530 "Panama" 532	"Saint Lucia" 533 "Saint Vincent e Grenadine" 534 "Saint Kitts e Nevis" ///
536	"Stati Uniti d'America" 602	"Argentina"  604	"Bolivia" 605	"Brasile" 606 "Cile" 608 "Colombia" 609	"Ecuador" 612 "Guyana" 614	"Paraguay" 615	"Peru" 16 "Suriname" ///	
617	"Trinidad e Tobago" 618	"Uruguay" 619 "Venezuela" 701 "Australia" 703 "Figi" 708 "Kiribati" 712	"Marshall, Isole" 713 "Micronesia, Stati Federati" 715 "Nauru" 719 "Nuova Zelanda" ///	
720	"Palau" 721	"Papua Nuova Guinea" 725 "Salomone, Isole" 727	"Samoa" 730	"Tonga" 731	"Tuvalu" 732 "Vanuatu" 999 "APOLIDE" 888 "altro" 777 "non indicato"

label define codici_regioni  1 "Piemonte" 2 "Valle D'Aosta" 3 "Lombardia" 4 "Trentino Alto-Adige" 5 "Veneto" 6 "Friuli Venezia Giulia" 7 "Liguria" 8 "Emilia Romagna" ///
9 "Toscana" 10 "Umbria" 11 "Marche" 12 "Lazio" 13 "Abruzzo" 14 "Molise" 15 "Campania" 16 "Puglia" 17 "Basilicata" 18 "Calabria" 19 "Sicilia" 20 "Sardegna" 

rename codreg cod_reg
lab values cod_reg codici_regioni
rename codpro_2011 provincia
lab values provincia codici_province
rename codcom_2011 cod_mun
lab var cod_mun "codice comune"
rename sesso sex 
lab values sex gender 
rename progper idc
lab var idc "identificativo individui per comune"
rename cittad nationality
lab define nat 1 "italiano" 2 "straniero"
lab values nationality nat
rename flag_res family
lab define fam 1 "famiglia" 2 "convivenza"
lab values family fam 
rename codfam idf
lab var idf "identificativo famiglia"
rename ncompstr nforeign
lab var nforeign "number of foreign family members"
rename ncomp nfam
lab var nfam "number of family members"

* Age

rename gnas born_d
rename mnas born_m 
rename anas born_y           
rename eta age
drop if age<18 
count
gen agec= .
replace agec=1 if age<=24
replace agec=2 if age >=25 & age<30
replace agec=3 if age >=30 & age<35
replace agec=4 if age >=35 & age<40
replace agec=5 if age >=40 & age<45
replace agec=6 if age >=45
lab define agecl 1 "24-" 2 "25-29" 3 "30-34" 4 "35-39" 5 "40-44" 6 "45+"
lab values agec agecl

* Education 

rename titstudioric educ
destring educ , replace
tab educ
label define educl  1 "no leggere" 2 "no titolo" 3 "elementari" 4 "medie" 5 "sup 2-3 anni" 6 "superiori" 7 "accademia" 8 "dip universitario" 9 "diploma accademico" 10 "laurea triennale" 11 "diploma accademico" 12 "laurea" 
lab values educ educl
gen high = educ>=5
lab var high "high school"
tab high
gen yedu= .
replace yedu= 0 if educ==1
replace yedu= 2 if educ==2
replace yedu= 5 if educ==3
replace yedu= 8 if educ==4
replace yedu= 11 if educ==5
replace yedu= 13 if educ==6
replace yedu= 13 if educ==7
replace yedu= 16 if educ==8
replace yedu= 16 if educ==9
replace yedu= 16 if educ==10
replace yedu= 18 if educ==11
replace yedu= 18 if educ==12

* Marital status

rename staciv ms
lab var ms "marital status"
label define stato_civile 1 "celibe/nubile" 2 "coniugato" 3 "separato di fatto" 4 "separato legalmente" 5 "divorziato" 6 "vedovo"
lab values ms stato_civile
tab ms
gen single= ms==1 | ms==4 | ms==5 | ms==6 // single sono celibi separati div e vedovi
tab single

* Origin 
rename anntra italy_year
lab var italy_year "anno del trasferimento in italia"
rename luonasmad m_born
destring m_born, replace
lab var m_born " luogo nascita madre"
lab define nascita 1 "italia" 2 "estero"
lab values m_born nascita
rename stanmad mbc
lab var mbc "mother born country"
lab values mbc cittadinanza
rename luonaspad f_born
destring f_born, replace
lab var f_born " luogo nascita padre"
lab values f_born nascita
rename stanpad fbc
lab var fbc "father born country"
lab values fbc cittadinanza
rename pronas born_prov 
lab var born_prov "provincia nascita"
lab values born_prov codici_province
rename regnas born_region
lab var born_region "regione nascita"
lab values born_region codici_regioni
rename estanas born_country
lab values born_country cittadinanza
rename stac nationality2
lab var nationality2 "cittadinanza"
lab values nationality2 cittadinanza
tab born_country
codebook born_country
gen bc=.
replace bc= born_country
replace bc= nationality2 if born_country==0 & nationality2>100 & m_born==2 & f_born==2 // sg
lab var bc "individual country of origin and SG"
codebook bc
drop if bc==999 | bc==998 // apolidi

gen nat= bc
merge m:1 nat using "$data\CodiciStatiEsteri.dta" , keepusing(EUII)
tab _merge
drop _merge
replace EUII=0 if bc==0
replace EUII=5 if nat==224 
replace EUII=6 if nat==258  
replace EUII=6 if nat==259  
replace EUII=6 if nat==260  
replace EUII=6 if nat==261  
replace EUII=9 if nat==317  
rename EUII group
drop nat  
gen origin=.
replace origin=0 if group==0 
replace origin=1 if group==1
replace origin=2 if group==2 | group==3
replace origin=3 if group==4 
replace origin=4 if group==5 
replace origin=5 if group==6 
replace origin=6 if group==7 
replace origin=7 if group==8 
lab define lorigin 0 "italian" 1 "eu" 2 "eu10+eu2" 3 "euother" 4 "africa" 5 "asia" 6 "america" 7 "oecd"
lab values origin lorigin
drop if origin==.
drop nat
  
* Keep singles 

keep if single==1
drop if age<18 
drop if age>61 
gen female = sex==2
gen male = sex==1
gen y = 2011
keep  y age sex yedu educ origin 

save "$c2011\\`name'_2011_descriptives.dta" , replace

}


clear
set more off
use "$c2011\agrigento_2011_descriptives.dta" , clear

global allprov2 alessandria  ancona arezzo ascolipiceno asti avellino barletta belluno benevento bergamo biella ///
bari bologna bolzano brescia brindisi cagliari caltanissetta campobasso carboniaiglesias caserta catania catanzaro ///
chieti como cosenza cremona crotone cuneo enna fermo ferrara firenze foggia forli frosinone genova gorizia grosseto ///
imperia isernia laquila laspezia latina lecce lecco livorno lodi lucca macerata mantova massacarrara matera mediocampidano messina ///
milano modena monzabrianza napoli novara nuoro ogliastra olbia oristano padova palermo parma pavia perugia pesarourbino pescara piacenza pisa pistoia ///
pordenone potenza prato ragusa ravenna reggiocalabria reggioemilia rieti rimini roma rovigo salerno sassari savona siena siracusa sondrio ///
taranto teramo terni torino trapani trento treviso trieste udine valleaosta varese venezia verbano vercelli verona vibovalentia vicenza viterbo

foreach name in $allprov2{
append using "$c2011\\`name'_2011_descriptives.dta"  
}

********************************************************************************
*  Table 2: Panel d. Singles in 2011, Males and Females
*  Number of observations in the dataset and summary statistics

gen area= 2
replace area=1 if origin==0
replace area=3 if origin==2
lab define areal 1 "italian"  3 "EU2004/2007" 2 "all other" 
label values area areal
collapse (sum) single (mean) age yedu  , by( area sex ) 

